package com.sgb.kjwl.view.ui.activity.self.publish;

import android.content.Context;
import android.content.Intent;
import androidx.databinding.DataBindingUtil;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.view.View;

import com.sgb.kjwl.AppActivity;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ActivityPublicMyPriceDetailsBinding;
import com.sgb.kjwl.view.ui.fragment.self.MyPriceDemandFragment;
import com.sgb.kjwl.view.ui.fragment.self.MyPriceInfoFragment;
import com.swgk.core.recyclerview.adapter.SlidingFragmentPagerAdapter;

import java.util.ArrayList;

/**
 * 租赁经营——我的报价——查看详情
 */
public class PublicMyPriceDetailsActivity extends AppActivity {


    private ActivityPublicMyPriceDetailsBinding binding;
    private String[] titles = {"需求信息", "我的报价信息"};
    private ArrayList<Fragment> mFragments;
    //报价单id
    private int priceId;

    public static void start(Context context) {
        start(context, 0);
    }

    //将报价单的id传递进来
    public static void start(Context context, int id) {
        Intent intent = new Intent();
        intent.setClass(context, PublicMyPriceDetailsActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        intent.putExtra("id",id);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void initView() {
        binding = DataBindingUtil.setContentView(PublicMyPriceDetailsActivity.this, R.layout.activity_public_my_price_details);
        binding.include.ivBack.setVisibility(View.VISIBLE);
        binding.include.mapView.setVisibility(View.GONE);
        binding.include.titleView.setVisibility(View.VISIBLE);
        binding.include.titleView.setText("查看详情");
        binding.include.rightView.setVisibility(View.GONE);
        binding.include.ivBack.setOnClickListener(view->finish());

        mFragments = new ArrayList<>();
        mFragments.add(MyPriceDemandFragment.newInstance(getIntent().getStringExtra("id")));
        mFragments.add(MyPriceInfoFragment.newInstance(getIntent().getStringExtra("id")));
        SlidingFragmentPagerAdapter mAdapetr = new SlidingFragmentPagerAdapter(getSupportFragmentManager(), mFragments);
        binding.viewpager.setAdapter(mAdapetr);
        binding.viewpager.setOffscreenPageLimit(2);
        binding.tablayout.setViewPager(binding.viewpager, titles);
//        binding.tablayout.setupWithViewPager(binding.viewpager);
//        binding.viewpager.setCurrentItem(0);
    }

    @Override
    protected void init() {
        priceId=getIntent().getIntExtra("id",0);

    }


}
